package posthttp;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @author chaird
 * @create 2022-03-02 22:10
 */
public class App {

  public static void main(String[] args) throws Exception {

    String str;

    str =
        "{\"code\":200,\"message\":\"success\",\"data\":{\"list\":[{\"username\":\"qq_61412871\",\"nickname\":\"一颗糖412\",\"userAvatar\":\"https://profile.csdnimg.cn/E/F/8/3_qq_61412871\",\"blogUrl\":\"https://blog.csdn.net/qq_61412871\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":\"\",\"id\":80563259},{\"username\":\"qq_37171353\",\"nickname\":\"CBeann\",\"userAvatar\":\"https://profile.csdnimg.cn/B/0/1/3_qq_37171353\",\"blogUrl\":\"https://blog.csdn.net/qq_37171353\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":\"明天的你会感激今天努力的自己。\",\"id\":80561745},{\"username\":\"weixin_67508017\",\"nickname\":\"laopenjin\",\"userAvatar\":\"https://profile.csdnimg.cn/3/A/F/3_weixin_67508017\",\"blogUrl\":\"https://blog.csdn.net/weixin_67508017\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80561696},{\"username\":\"fmhabc123\",\"nickname\":\"fmhabc123\",\"userAvatar\":\"https://profile.csdnimg.cn/2/8/3/3_fmhabc123\",\"blogUrl\":\"https://blog.csdn.net/fmhabc123\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80561441},{\"username\":\"kellyorange\",\"nickname\":\"小明棕\",\"userAvatar\":\"https://profile.csdnimg.cn/0/F/F/3_kellyorange\",\"blogUrl\":\"https://blog.csdn.net/kellyorange\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80561364},{\"username\":\"weixin_56058644\",\"nickname\":\"Dꪮ . hꪮmꫀꪝꪮʀk .\",\"userAvatar\":\"https://profile.csdnimg.cn/F/0/8/3_weixin_56058644\",\"blogUrl\":\"https://blog.csdn.net/weixin_56058644\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":\"\",\"id\":80560319},{\"username\":\"m0_67589172\",\"nickname\":\"m0_67589172\",\"userAvatar\":\"https://profile.csdnimg.cn/8/4/C/3_m0_67589172\",\"blogUrl\":\"https://blog.csdn.net/m0_67589172\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80560037},{\"username\":\"banianyiwanbei\",\"nickname\":\"新呵呵\",\"userAvatar\":\"https://profile.csdnimg.cn/4/7/9/3_banianyiwanbei\",\"blogUrl\":\"https://blog.csdn.net/banianyiwanbei\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80559516},{\"username\":\"weixin_46670664\",\"nickname\":\"&radic;+&amp;\",\"userAvatar\":\"https://profile.csdnimg.cn/F/A/8/3_weixin_46670664\",\"blogUrl\":\"https://blog.csdn.net/weixin_46670664\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80559052},{\"username\":\"weixin_65346883\",\"nickname\":\"Kani553\",\"userAvatar\":\"https://profile.csdnimg.cn/C/9/A/3_weixin_65346883\",\"blogUrl\":\"https://blog.csdn.net/weixin_65346883\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80558897},{\"username\":\"zhouwenjin_\",\"nickname\":\"ZHOUWENJIN_\",\"userAvatar\":\"https://profile.csdnimg.cn/7/2/3/3_zhouwenjin_\",\"blogUrl\":\"https://blog.csdn.net/zhouwenjin_\",\"loginUserNameIsFollow\":true,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80558684},{\"username\":\"m0_56718628\",\"nickname\":\"m0_56718628\",\"userAvatar\":\"https://profile.csdnimg.cn/8/C/8/3_m0_56718628\",\"blogUrl\":\"https://blog.csdn.net/m0_56718628\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80558602},{\"username\":\"m0_64208396\",\"nickname\":\"m0_64208396\",\"userAvatar\":\"https://profile.csdnimg.cn/8/D/4/3_m0_64208396\",\"blogUrl\":\"https://blog.csdn.net/m0_64208396\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80558295},{\"username\":\"m0_66487381\",\"nickname\":\"m0_66487381\",\"userAvatar\":\"https://profile.csdnimg.cn/7/9/9/3_m0_66487381\",\"blogUrl\":\"https://blog.csdn.net/m0_66487381\",\"loginUserNameIsFollow\":true,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80558205},{\"username\":\"qq_40381018\",\"nickname\":\"qq_40381018\",\"userAvatar\":\"https://profile.csdnimg.cn/D/F/6/3_qq_40381018\",\"blogUrl\":\"https://blog.csdn.net/qq_40381018\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80557644},{\"username\":\"m0_67543797\",\"nickname\":\"m0_67543797\",\"userAvatar\":\"https://profile.csdnimg.cn/B/4/2/3_m0_67543797\",\"blogUrl\":\"https://blog.csdn.net/m0_67543797\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80556821},{\"username\":\"weixin_65733420\",\"nickname\":\"海是孤岛的泪@699\",\"userAvatar\":\"https://profile.csdnimg.cn/5/A/2/3_weixin_65733420\",\"blogUrl\":\"https://blog.csdn.net/weixin_65733420\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80556614},{\"username\":\"m0_66632540\",\"nickname\":\"m0_66632540\",\"userAvatar\":\"https://profile.csdnimg.cn/4/5/3/3_m0_66632540\",\"blogUrl\":\"https://blog.csdn.net/m0_66632540\",\"loginUserNameIsFollow\":true,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80556456},{\"username\":\"qq_18572713\",\"nickname\":\"尒白\",\"userAvatar\":\"https://profile.csdnimg.cn/8/9/D/3_qq_18572713\",\"blogUrl\":\"https://blog.csdn.net/qq_18572713\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":\"\",\"id\":80555785},{\"username\":\"qq_43796151\",\"nickname\":\"14#3101一盐城\",\"userAvatar\":\"https://profile.csdnimg.cn/A/4/3/3_qq_43796151\",\"blogUrl\":\"https://blog.csdn.net/qq_43796151\",\"loginUserNameIsFollow\":false,\"blogExpert\":false,\"briefIntroduction\":null,\"id\":80555726}]}}";

    // 把Json对象解析对象
    JsonRootBean jsonRootBean = JSONUtil.toBean(str, JsonRootBean.class);

    Data data = jsonRootBean.getData();
    // 获取用户集合
    List<MyList> list = data.getList();

    for (MyList myList : list) {
      try {
        TimeUnit.SECONDS.sleep(1);
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
      }

      String username = myList.getUsername();

      // json格式的参数，我们可以用map来封装参数，然后将参数转换为json格式
      Map<String, Object> params = new HashMap<>();
      params.put("detailSourceName", "个人主页");
      // 对方的ID
      params.put("follow", username);
      // 自己的ID
      params.put("username", "qq_37171353");
      params.put("fromType", "pc");
      params.put("source", "ME");
      String paramsJson = JSON.toJSONString(params); // 将参数转换为json字符串
      System.out.println(paramsJson);

      HttpClient client = new HttpClient(); // 客户端实例化
      PostMethod postMethod =
          new PostMethod(
              "https://mp-action.csdn.net/interact/wrapper/pc/fans/v1/api/follow"); // 请求方法post，可以将请求路径传入构造参数中
      postMethod.addRequestHeader("Content-type", "application/json; charset=utf-8");
      postMethod.addRequestHeader(":authority", "mp-action.csdn.net");
      postMethod.addRequestHeader(":method", "POST");
      postMethod.addRequestHeader(":method", "POST");
      postMethod.addRequestHeader(":path", "/interact/wrapper/pc/fans/v1/api/follow");
      postMethod.addRequestHeader(":scheme", "https");
      postMethod.addRequestHeader("accept", "application/json, text/plain, */*");
      postMethod.addRequestHeader("origin", "https://csp1999.blog.csdn.net");
      postMethod.addRequestHeader("referer", "https://csp1999.blog.csdn.net/?type=blog");
      postMethod.addRequestHeader(
          "user-agent",
          "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.82 Safari/537.36");
      String cookie =
          "uuid_tt_dd=10_4665918760-1594104503838-914730; UN=qq_37171353; Hm_ct_6bcd52f51e9b3dce32bec4a3997715ac=6525*1*10_4665918760-1594104503838-914730!5744*1*qq_37171353; __gpi=00000000-0000-0000-0000-000000000000&Y3Nkbi5uZXQ=&Lw==; channel_id=994397c1; UM_distinctid=17c15e8498d17-0d6c7574e0da34-4343363-144000-17c15e8498e33b; ssxmod_itna=Qq0x0GiQi=itF4BPGKO47ujnDyiUdTdDRer8epD05TeGzDAxn40iDtPoN1e=8QU0Dxtf4tYc+xHWZO4LmdgQ8m3qaMPx0aDbqGkq3pAeGGjxBYDQxAYDGDDPDocPD1D3qDkD7h6CMy1qGWDm4kDWPDYxDrjOKDRxi7DD5Qkx07DQ5kHQGxjpBF=FHpu=i+omDkD7ypDlc4j9Om6/fxMp7Ev3uYHDGd/0k4Y0d5=Q454f+ODlIRDC91c2HHaRMkZhvGZBnYTex3wiieqARYo02N=i0xhHr0diDoH0r3oi0YG6i4Pv+ylkDDiPQdYhEYD=; ssxmod_itna2=Qq0x0GiQi=itF4BPGKO47ujnDyiUdTdDRer8DnKS0BDDsowdHDLG=bv60xTk7v0cND6mG9DqUfZqqx7qlOM4jorOB4EazofRQYHLX0e6hdtm16D=nsp=99a2AwK=1BOwobFj3nexdSvsC8AKiMUAYW=IFYt9AEQg7+qDOGIf/dtqL+0rtwDY1eTIKoUPlT6LK+t8tdRF8pItVEK4TBQA+nbAYeWwS=2B0Oih68Xhqabk9M6iVgQtt13XmaAdEErIAcPCD13C+EczQC3V0OSLsxTAI3aig2NwBO12gjzOXXfgXzsA9yAEnpMZQUPp6iqgCi48me86KRigcw58i5KrY3t+e2Q+ref2tIq5+qzierFrtUfTFbbIb212r/2HI5tWKIG=LOmjOqi/q91TtIvGWuelG+hwxnYWRL+PrgCUBnj73tpPazAjdiDWDG2fTq3csj2DR4KfbqI+zFKx0uPGReQ0FRwxbLWRabtkQ9hWQ+vfkzmh8Vpk7bx7RPnLKGrzKCzhnHnFKArd75xl3CsCmhm7lbFKD5fh5QG7DSIMCLKxDFqD+pmBRhxlp7W3YChS34hmG4Dqi7k4lpFkMiDq4l4YnGomMrRPwvGq7MqXCmwx70xwq8IXlEPqtYD=; UserName=qq_37171353; UserInfo=655a27289dde4932a85f35027b2091c0; UserToken=655a27289dde4932a85f35027b2091c0; UserNick=CBeann; AU=B01; BT=1643897914637; p_uid=U010000; Hm_up_6bcd52f51e9b3dce32bec4a3997715ac={\"uid_\":{\"value\":\"qq_37171353\",\"scope\":1},\"islogin\":{\"value\":\"1\",\"scope\":1},\"isonline\":{\"value\":\"1\",\"scope\":1},\"isvip\":{\"value\":\"0\",\"scope\":1}}; _ga=GA1.2.1296246211.1596438441; __gads=ID=adf77891da5a0b47-221049ae3ecd003f:T=1628520900:RT=1644807208:S=ALNI_MYJgA-3veg4Y29kTurq4QxDd_-40w; _ga_VHSCGE70LW=GS1.1.1644853545.18.1.1644853587.0; FCNEC=[[\"AKsRol91ieUruokj0aBkWQKwrY6cubTp9-kUTi5ePiY0f9i_DvWUg42rsmW94Kubqi__FyHN4vpeqvf2O7p1fBft6T43Tr7xIgwQcg9goNPwkyrntBfIt4qhtFsKjn0XaDgBFy4FD6WBWXC0_4xxXsiS23ctNOF4CQ==\"],null,[]]; c_dl_fpage=/download/chengzi_cm/11231978; c_dl_prid=1645774211298_904558; c_dl_rid=1645774242649_157835; c_dl_fref=https://www.baidu.com/link; c_dl_um=distribute.pc_relevant_t0.none-task-download-2~default~CTRLIST~Paid-1.pc_relevant_paycolumn_v3; dc_sid=4397aba845d45c495f5dbf802e8384f1; c_segment=10; dc_session_id=10_1646273828660.103190; c_first_ref=www.baidu.com; c_first_page=https://blog.csdn.net/qq_37171353/; Hm_lvt_6bcd52f51e9b3dce32bec4a3997715ac=1646224729,1646224786,1646224904,1646273932; c_utm_term=兴趣使然的草帽路飞; c_utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-2-117849419.pc_search_result_cache; log_Id_view=10711; referrer_search=1646274024273; c_pref=https://so.csdn.net/so/search?q=%E5%85%B4%E8%B6%A3%E4%BD%BF%E7%84%B6%E7%9A%84%E8%8D%89%E5%B8%BD%E8%B7%AF%E9%A3%9E&t=&u=&utm_term=%E5%85%B4%E8%B6%A3%E4%BD%BF%E7%84%B6%E7%9A%84%E8%8D%89%E5%B8%BD%E8%B7%AF%E9%A3%9E&utm_medium=distribute.pc_toolbar_associateword.none-task-associate_word-opensearch_query-6-%E5%85%B4%E8%B6%A3%E4%BD%BF%E7%84%B6%E7%9A%84%E8%8D%89%E5%B8%BD%E8%B7%AF%E9%A3%9E.nonecase&depth_1-utm_source=distribute.pc_toolbar_associateword.none-task-associate_word-opensearch_query-6-%E5%85%B4%E8%B6%A3%E4%BD%BF%E7%84%B6%E7%9A%84%E8%8D%89%E5%B8%BD%E8%B7%AF%E9%A3%9E.nonecase&request_id=164612684816780366555523&opensearch_request_id=164612684816780366555523; c_ref=https://blog.csdn.net/weixin_43591980/article/details/117849419?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522164627401916780271549778%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=164627401916780271549778&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-2-117849419.pc_search_result_cache&utm_term=%E5%85%B4%E8%B6%A3%E4%BD%BF%E7%84%B6%E7%9A%84%E8%8D%89%E5%B8%BD%E8%B7%AF%E9%A3%9E&spm=1018.2226.3001.4187; c_utm_source=14998968; utm_source=14998968; c_page_id=default; dc_tos=r85d6l; log_Id_pv=5315; Hm_lpvt_6bcd52f51e9b3dce32bec4a3997715ac=1646274046; log_Id_click=3930";
      postMethod.addRequestHeader("cookie", cookie);

      byte[] requestBytes = paramsJson.getBytes("utf-8"); // 将参数转为二进制流
      InputStream inputStream = new ByteArrayInputStream(requestBytes, 0, requestBytes.length);
      RequestEntity requestEntity =
          new InputStreamRequestEntity(
              inputStream, requestBytes.length, "application/json; charset=utf-8"); // 请求体
      postMethod.setRequestEntity(requestEntity); // 将参数放入请求体

      int i = client.executeMethod(postMethod); // 执行方法
      System.out.println("请求状态" + i);
      // 这里因该有判断的，根据请求状态判断请求是否成功，然后根据第三方接口返回的数据格式，解析出我们需要的数据

      byte[] responseBody = postMethod.getResponseBody(); // 得到相应数据
      String s = new String(responseBody);
      System.out.println(s);
    }

    // json格式的参数，我们可以用map来封装参数，然后将参数转换为json格式
    Map<String, Object> params = new HashMap<>();
    params.put("detailSourceName", "个人主页");
    params.put("follow", "weixin_43122090");
    params.put("fromType", "pc");
    params.put("source", "ME");

    params.put("username", "qq_37171353");

    String paramsJson = JSON.toJSONString(params); // 将参数转换为json字符串
    System.out.println(paramsJson);

    // String
    // params="{\"articleID\":44,\"columnID\":44,\"desColumnID\":44,\"title\":\"44\",\"subTitle\":\"44\",\"leadTitle\":\"44\",\"abstract\":\"44\",\"articleType\":0,\"source\":44\",\"tag\":\"44\",\"optUser\":\"44\",\"author\":\"44\",\"editor\":\"44\",\"liability\":\"44\",\"status\":1,\"content\":\"44\",\"imgUrl\":\"http://dev-file.aimingtai.com/webdata/45/images/2018/0829/15355154473121002.jpg\"}";

    // 服务端通常是根据请求头（headers）中的 Content-Type 字段来获知请求中的消息主体是用何种方式编码，再对主体进行解析。所以说到 POST 提交数据方案，包含了
    // Content-Type 和消息主体编码方式两部分
    HttpClient client = new HttpClient(); // 客户端实例化
    PostMethod postMethod =
        new PostMethod(
            "https://mp-action.csdn.net/interact/wrapper/pc/fans/v1/api/follow"); // 请求方法post，可以将请求路径传入构造参数中
    postMethod.addRequestHeader("Content-type", "application/json; charset=utf-8");
    postMethod.addRequestHeader(":authority", "mp-action.csdn.net");
    postMethod.addRequestHeader(":method", "POST");
    postMethod.addRequestHeader(":method", "POST");
    postMethod.addRequestHeader(":path", "/interact/wrapper/pc/fans/v1/api/follow");
    postMethod.addRequestHeader(":scheme", "https");
    postMethod.addRequestHeader("accept", "application/json, text/plain, */*");
    postMethod.addRequestHeader("origin", "https://csp1999.blog.csdn.net");
    postMethod.addRequestHeader("referer", "https://csp1999.blog.csdn.net/?type=blog");
    postMethod.addRequestHeader(
        "user-agent",
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.82 Safari/537.36");

    String cookie =
        "uuid_tt_dd=10_4665918760-1594104503838-914730; UN=qq_37171353; Hm_ct_6bcd52f51e9b3dce32bec4a3997715ac=6525*1*10_4665918760-1594104503838-914730!5744*1*qq_37171353; __gpi=00000000-0000-0000-0000-000000000000&Y3Nkbi5uZXQ=&Lw==; channel_id=994397c1; UM_distinctid=17c15e8498d17-0d6c7574e0da34-4343363-144000-17c15e8498e33b; ssxmod_itna=Qq0x0GiQi=itF4BPGKO47ujnDyiUdTdDRer8epD05TeGzDAxn40iDtPoN1e=8QU0Dxtf4tYc+xHWZO4LmdgQ8m3qaMPx0aDbqGkq3pAeGGjxBYDQxAYDGDDPDocPD1D3qDkD7h6CMy1qGWDm4kDWPDYxDrjOKDRxi7DD5Qkx07DQ5kHQGxjpBF=FHpu=i+omDkD7ypDlc4j9Om6/fxMp7Ev3uYHDGd/0k4Y0d5=Q454f+ODlIRDC91c2HHaRMkZhvGZBnYTex3wiieqARYo02N=i0xhHr0diDoH0r3oi0YG6i4Pv+ylkDDiPQdYhEYD=; ssxmod_itna2=Qq0x0GiQi=itF4BPGKO47ujnDyiUdTdDRer8DnKS0BDDsowdHDLG=bv60xTk7v0cND6mG9DqUfZqqx7qlOM4jorOB4EazofRQYHLX0e6hdtm16D=nsp=99a2AwK=1BOwobFj3nexdSvsC8AKiMUAYW=IFYt9AEQg7+qDOGIf/dtqL+0rtwDY1eTIKoUPlT6LK+t8tdRF8pItVEK4TBQA+nbAYeWwS=2B0Oih68Xhqabk9M6iVgQtt13XmaAdEErIAcPCD13C+EczQC3V0OSLsxTAI3aig2NwBO12gjzOXXfgXzsA9yAEnpMZQUPp6iqgCi48me86KRigcw58i5KrY3t+e2Q+ref2tIq5+qzierFrtUfTFbbIb212r/2HI5tWKIG=LOmjOqi/q91TtIvGWuelG+hwxnYWRL+PrgCUBnj73tpPazAjdiDWDG2fTq3csj2DR4KfbqI+zFKx0uPGReQ0FRwxbLWRabtkQ9hWQ+vfkzmh8Vpk7bx7RPnLKGrzKCzhnHnFKArd75xl3CsCmhm7lbFKD5fh5QG7DSIMCLKxDFqD+pmBRhxlp7W3YChS34hmG4Dqi7k4lpFkMiDq4l4YnGomMrRPwvGq7MqXCmwx70xwq8IXlEPqtYD=; UserName=qq_37171353; UserInfo=655a27289dde4932a85f35027b2091c0; UserToken=655a27289dde4932a85f35027b2091c0; UserNick=CBeann; AU=B01; BT=1643897914637; p_uid=U010000; Hm_up_6bcd52f51e9b3dce32bec4a3997715ac={\"uid_\":{\"value\":\"qq_37171353\",\"scope\":1},\"islogin\":{\"value\":\"1\",\"scope\":1},\"isonline\":{\"value\":\"1\",\"scope\":1},\"isvip\":{\"value\":\"0\",\"scope\":1}}; _ga=GA1.2.1296246211.1596438441; __gads=ID=adf77891da5a0b47-221049ae3ecd003f:T=1628520900:RT=1644807208:S=ALNI_MYJgA-3veg4Y29kTurq4QxDd_-40w; _ga_VHSCGE70LW=GS1.1.1644853545.18.1.1644853587.0; FCNEC=[[\"AKsRol91ieUruokj0aBkWQKwrY6cubTp9-kUTi5ePiY0f9i_DvWUg42rsmW94Kubqi__FyHN4vpeqvf2O7p1fBft6T43Tr7xIgwQcg9goNPwkyrntBfIt4qhtFsKjn0XaDgBFy4FD6WBWXC0_4xxXsiS23ctNOF4CQ==\"],null,[]]; c_dl_fpage=/download/chengzi_cm/11231978; c_dl_prid=1645774211298_904558; c_dl_rid=1645774242649_157835; c_dl_fref=https://www.baidu.com/link; c_dl_um=distribute.pc_relevant_t0.none-task-download-2~default~CTRLIST~Paid-1.pc_relevant_paycolumn_v3; dc_sid=4397aba845d45c495f5dbf802e8384f1; c_segment=10; dc_session_id=10_1646273828660.103190; c_first_ref=www.baidu.com; c_first_page=https://blog.csdn.net/qq_37171353/; Hm_lvt_6bcd52f51e9b3dce32bec4a3997715ac=1646224729,1646224786,1646224904,1646273932; c_utm_term=兴趣使然的草帽路飞; c_utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-2-117849419.pc_search_result_cache; log_Id_view=10711; referrer_search=1646274024273; c_pref=https://so.csdn.net/so/search?q=%E5%85%B4%E8%B6%A3%E4%BD%BF%E7%84%B6%E7%9A%84%E8%8D%89%E5%B8%BD%E8%B7%AF%E9%A3%9E&t=&u=&utm_term=%E5%85%B4%E8%B6%A3%E4%BD%BF%E7%84%B6%E7%9A%84%E8%8D%89%E5%B8%BD%E8%B7%AF%E9%A3%9E&utm_medium=distribute.pc_toolbar_associateword.none-task-associate_word-opensearch_query-6-%E5%85%B4%E8%B6%A3%E4%BD%BF%E7%84%B6%E7%9A%84%E8%8D%89%E5%B8%BD%E8%B7%AF%E9%A3%9E.nonecase&depth_1-utm_source=distribute.pc_toolbar_associateword.none-task-associate_word-opensearch_query-6-%E5%85%B4%E8%B6%A3%E4%BD%BF%E7%84%B6%E7%9A%84%E8%8D%89%E5%B8%BD%E8%B7%AF%E9%A3%9E.nonecase&request_id=164612684816780366555523&opensearch_request_id=164612684816780366555523; c_ref=https://blog.csdn.net/weixin_43591980/article/details/117849419?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522164627401916780271549778%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=164627401916780271549778&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-2-117849419.pc_search_result_cache&utm_term=%E5%85%B4%E8%B6%A3%E4%BD%BF%E7%84%B6%E7%9A%84%E8%8D%89%E5%B8%BD%E8%B7%AF%E9%A3%9E&spm=1018.2226.3001.4187; c_utm_source=14998968; utm_source=14998968; c_page_id=default; dc_tos=r85d6l; log_Id_pv=5315; Hm_lpvt_6bcd52f51e9b3dce32bec4a3997715ac=1646274046; log_Id_click=3930";
    postMethod.addRequestHeader("cookie", cookie);

    byte[] requestBytes = paramsJson.getBytes("utf-8"); // 将参数转为二进制流
    InputStream inputStream = new ByteArrayInputStream(requestBytes, 0, requestBytes.length);
    RequestEntity requestEntity =
        new InputStreamRequestEntity(
            inputStream, requestBytes.length, "application/json; charset=utf-8"); // 请求体
    postMethod.setRequestEntity(requestEntity); // 将参数放入请求体

    int i = client.executeMethod(postMethod); // 执行方法
    System.out.println("请求状态" + i);
    // 这里因该有判断的，根据请求状态判断请求是否成功，然后根据第三方接口返回的数据格式，解析出我们需要的数据

    byte[] responseBody = postMethod.getResponseBody(); // 得到相应数据
    String s = new String(responseBody);
    System.out.println(s);
  }
}
